var t = getApp();

Page({
    data: {
        member_phone: "",
        v2_code: "",
        count: "",
        isOpenCaptcha: !1,
        imgCodeLink: "",
        captcha: ""
    },
    onLoad: function(t) {
        this.setData({
            card_id: t.card_id
        }), this.getMemberPhone();
    },
    onShow: function() {},
    changeCaptcha: function(t) {
        var a = t.detail.value;
        this.setData({
            captcha: a
        });
    },
    v2CodeInp: function(t) {
        var a = t.detail.value;
        this.setData({
            v2_code: a
        });
    },
    getMemberPhone: function() {
        var a = this, e = this, c = t.getNetAddresss("plugin.converge_pay.frontend.controllers.quick-pay-bank-card.get-mobile");
        t._getNetWork({
            url: c,
            showToastIn: !1,
            success: function(c) {
                var n = c.data;
                1 === n.result ? (a.setData({
                    check_open: n.data.sms_check_open
                }), n.data.get_captcha && n.data.get_captcha.captcha && a.setData({
                    imgCodeLink: n.data.get_captcha.captcha.img,
                    isOpenCaptcha: n.data.get_captcha.captcha.status
                }), n.data.mobile ? e.setData({
                    member_phone: n.data.mobile
                }) : wx.showModal({
                    title: "提示",
                    content: "商城会员没有绑定手机号，请绑定手机号",
                    success: function(t) {
                        t.confirm ? wx.navigateTo({
                            url: "/packageA/member/editmobile/editmobile"
                        }) : t.cancel && wx.navigateBack({
                            delta: 1
                        });
                    }
                })) : t.tips(n.msg);
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getCaptchaImg: function() {
        var a = this, e = t.getNetAddresss("plugin.converge_pay.frontend.controllers.quick-pay-bank-card.get-mobile");
        t._getNetWork({
            url: e,
            data: {},
            success: function(e) {
                var c = e.data;
                1 !== c.result && t.tips(c.msg), c.data.get_captcha && c.data.get_captcha.captcha && a.setData({
                    imgCodeLink: c.data.get_captcha.captcha.img
                });
            }
        });
    },
    VerificationCode: function() {
        if (1 == this.data.isOpenCaptcha && t._isTextEmpty(this.data.captcha)) t.tips("请填写图形验证码"); else {
            wx.showLoading({
                title: "发送中"
            });
            var a = this, e = t.getNetAddresss("plugin.converge_pay.frontend.controllers.quick-pay-bank-card.send-code");
            t._getNetWork({
                showToastIn: !1,
                url: e,
                data: {
                    captcha: this.data.captcha
                },
                success: function(t) {
                    var e = t.data;
                    wx.hideLoading(), 1 == e.result ? a.getCode() : wx.showToast({
                        title: e.msg,
                        icon: "none"
                    });
                },
                fail: function(t) {}
            });
        }
    },
    getCode: function() {
        var t = this;
        this.data.timer || (this.data.count = 60, this.data.timer = setInterval(function() {
            t.data.count > 0 && t.data.count <= 60 ? (t.data.count--, t.setData({
                count: t.data.count
            })) : (clearInterval(t.timer), t.data.count = 0, t.data.timer = null, t.setData({
                count: t.data.count,
                timer: t.data.timer
            }));
        }, 1e3));
    },
    confirmRemoveBank: function() {
        if (t._isTextEmpty(this.data.v2_code)) t.tips("请输入验证码"); else {
            var a = t.getNetAddresss("plugin.converge_pay.frontend.controllers.quick-pay-bank-card.del");
            t._getNetWork({
                showToastIn: !1,
                url: a,
                data: {
                    card_id: this.data.card_id,
                    code: this.data.v2_code
                },
                success: function(a) {
                    var e = a.data;
                    t.tips(e.msg), 1 == e.result && wx.navigateBack({
                        delta: 1
                    });
                },
                fail: function(t) {}
            });
        }
    },
    onShareAppMessage: function() {},
    onHide: function() {
        this.data.timer && clearInterval(this.data.timer);
    }
});